package com.linkage.util.xml;


import java.io.ByteArrayInputStream;

import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;

import com.linkage.util.exception.UtilException;
import com.linkage.util.xml.MyXMLVisitor;
import com.linkage.util.xml.XMLProperties;

/**
 * @author Administrator
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class XMLStringProperties extends XMLProperties{
	
	public XMLStringProperties(String xmlString) throws UtilException {
		super();
		try {
			SAXReader reader = new SAXReader();
			ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes());
			doc = reader.read(in);
			doc.getRootElement().accept(
					new MyXMLVisitor(propertiesCache, attributesCache));
			doc.setXMLEncoding("gb2312");
		} catch (DocumentException e) {
			throw new UtilException(e, this.getClass());
		}
	}


}
